class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


def mergeTwoLists(l1: ListNode, l2: ListNode) -> ListNode:
    prehead  = ListNode(-1)
    prev = prehead
    while (l1 and l2):
        if l1.val <= l2.val:
            prev.next = l1
            l1 = l1.next
        else:
            prev.next = l2
            l2 = l2.next
        prev = prev.next
    prev.next = l1 if l1 is not None else l2
    return prehead.next

def removeDuplicates(nums: [int]) -> int:
    i = 0
    for j in range(1,len(nums)):
        if(nums[i] != nums[j]):
            i = i+1
            nums[i] = nums[j]

    return i + 1

def removeElement(nums: [int], val: int) -> int:
    i = 0
    for j in range(0, len(nums)):
       if(nums[j] != val):
            nums[i] = nums[j]
            i = i + 1
    return  i

if __name__ == '__main__':
    nums = [1,2,3,4,4,5,6,7,8,8]
    print(removeElement(nums,8))

